package com.example.oom;

import java.util.ArrayList;

/**
 * Created by Administrator on 2020-3-13 0013.
 */
public class OOM {
    byte[] bytes = new byte[1024 * 1024];
    public static void main(String[] args) {
        Long totalMemory= Runtime.getRuntime().totalMemory();
        long maxMemory = Runtime.getRuntime().maxMemory();
        System.out.println("totalMemory:"+(totalMemory/1024/1024)+"M");
        System.out.println("maxMemory:"+(maxMemory/1024/1024)+"M");

        ArrayList<OOM> objects = new ArrayList<>();
        int count=0;
        while (true){
            objects.add(new OOM());
            count++;
            System.out.println("count:"+count);
        }

    }
}
